﻿#region Copyright(c) 2006 ZO, All right reserved.
// -----------------------------------------------------------------------------
// Copyright(c) 2006 ZO, All right reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   1.  Redistribution of source code must retain the above copyright notice,
//       this list of conditions and the following disclaimer.
//   2.  Redistribution in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//   3.  The name of the author may not be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -----------------------------------------------------------------------------
#endregion


#region Using directives

using System;
using System.ComponentModel;
using ArgumentNullException=ZO.SmartCore.Core.ArgumentNullException;

#endregion

namespace ZO.SmartCore.Xml
{
    /// <summary>
    /// Represents a processing instruction, which XML defines to keep processor-specific 
    /// information in the text of the document. 
    /// </summary>
    public class ProcessingInstruction : Node
    {

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="ProcessingInstruction"/> class.
        /// </summary>
        /// <param name="target">The name of the processing instruction. </param>
        /// <param name="data">The data for the processing instruction. .</param>
        public ProcessingInstruction(string target, string data) : base(data)
        {

            if (String.IsNullOrEmpty(target))
            {
                throw new ArgumentNullException("target");
            } // if
            this._Target = target;
        }
        #endregion

        #region Destructor

        #endregion

        #region Fields
        private string _Target;
        #endregion

        #region Events

        #endregion

        #region Operators

        #endregion

        #region Properties

        /// <summary>
        /// Gets the target of the processing instruction..
        /// </summary>
        /// <value>The target of the processing instruction.</value>
        public virtual string Target
        {
            get
            {
                return this._Target;
            }
        }

        /// <summary>
        /// Gets or sets the content of the processing instruction, excluding the target.
        /// </summary>
        /// <value>content of the processing instruction, excluding the target.</value>
        public virtual string Data
        {
            get
            {
                return this.Value;
            }
        }

        /// <summary>
        /// Gets or sets the value of the node.
        /// </summary>
        /// <value></value>
        /// <returns>The value returned depends on the <see cref="NodeType"></see> of the node: Type Value Attribute The value of the attribute. CDATASection The content of the CDATA Section. Comment The content of the comment. Document null. DocumentFragment null. DocumentType null. Element null. You can use the <see cref="P:System.Xml.XmlElement.InnerText"></see> or <see cref="P:System.Xml.XmlElement.InnerXml"></see> properties to access the value of the element node. Entity null. EntityReference null. Notation null. ProcessingInstruction The entire content excluding the target. Text The content of the text node. SignificantWhitespace The white space characters. White space can consist of one or more space characters, carriage returns, line feeds, or tabs. Whitespace The white space characters. White space can consist of one or more space characters, carriage returns, line feeds, or tabs. XmlDeclaration The content of the declaration (that is, everything between &lt;?xml and ?&gt;). </returns>
        /// <exception cref="System.InvalidOperationException">Setting the value of a node that is not supposed to have a value (for example, an Element node). </exception>
        /// <exception cref="System.ArgumentException">Setting the value of a node that is read-only. </exception>
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public override string Value
        {
            get
            {
                return base.Value;
            }
            set
            {
                base.Value = value;
            }
        }
        #endregion

        #region Methods
     
        /// <summary>
        /// When overridden in a derived class, gets the type of the current node.
        /// </summary>
        /// <value></value>
        /// <returns>One of the <see cref="NodeType"></see> values.</returns>
        public override NodeType NodeType
        {
            get { return NodeType.ProcessingInstruction; }
        }

        /// <summary>
        /// Adds the specified node to the end of the list of child nodes, of this node.
        /// </summary>
        /// <param name="newChild">The node to add</param>
        public override void AddChild(Node newChild)
        {
            //Do Nothing
        }
        #endregion

     
    }
}
